// device.h

// Copyright (C) 2010  traxex

// Author: 	traxex <traxex@yahoo.cn>
// Created: 	29 Jul 2010
// Version: 	1.0

#pragma once

namespace traxex{
namespace cuda{

class Device: public cudaDeviceProp{
  public:
    enum DeviceFlags{
        ScheduleAuto,
        ScheduleSpin,
        ScheduleYield,
        BlockingSync,
        MapHost,
        LmemResizeToMax
    };
  public:
    static size_t freemem(){
        size_t fm, am;
        _safecall( cudaMemGetInfo(&fm, &am));
        return fm;
    }
    static int count(){
        int n;
        _safecall( cudaGetDeviceCount(&n));
        return n;
    }
    static void set( int id){
        _safecall( cudaSetDevice( id));
    }
    Device( int id){
        _safecall( cudaGetDeviceProperties( this, id));
    }

    void print();
	    
    static void set_flags( DeviceFlags df){
        _safecall( cudaSetDeviceFlags(df));
    }
};
}
}
#include <traxex/cuda_impl/device.h>
